﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

using H2.NET.Business;

namespace H2.NET.Web.Pages
{
    public partial class Purchasing : TaskControl
    {
        #region 属性 Public
        public string FORM
        {
            get
            {
                return (Parent as TabMaterial).Status.FORM;
            }
        }

        public string Category
        {
            get
            {
                return (Parent as TabMaterial).Status.Category;
            }
        }

        public string Action
        {
            get
            {
                return (Parent as TabMaterial).Status.Purchasing;
            }
        }

        private bool IsLoaded
        {
            get
            {
                return ViewState["IsLoaded"] == null ? false : (bool)ViewState["IsLoaded"];
            }
            set { ViewState["IsLoaded"] = value; }
        }

        private bool IsUsed
        {
            get
            {
                //return !(string.IsNullOrEmpty(FORM) || string.IsNullOrEmpty(Action)
                //        || (FORM != "FORM-002" && FORM != "FORM-009" && FORM != "FORM-036" && FORM != "FORM-043"));
                return !string.IsNullOrEmpty(Action);
            }
        }
        #endregion

        #region 事件 页面加载
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Visible = IsUsed;
        }
        #endregion

        #region 事件 PUR_Classification 
        protected void PUR_Special_Procurement_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (PUR_Special_Procurement.SelectedValue == "10")
            {
                PUR_Stock_det_grp.Text = "0001";
                SetForeColor(Color.Orange, PUR_Stock_det_grp_L);
                SetEnable(false, PUR_Stock_det_grp);
            }
            else
            {
                PUR_Stock_det_grp.Text = "";
                SetEnable(true, PUR_Stock_det_grp);
                SetForeColor(Color.Orange, PUR_Stock_det_grp_L);
            }
        }
        protected void PUR_Classification_SelectedIndexChanged(object sender, EventArgs e)
        {
            SetVisible(true, PUR_Shape, PUR_Top_Diameter, PUR_Bottom_Diameter, PUR_Height, PUR_Length, PUR_Width, PUR_Internalcoating, PUR_Decoration, PUR_Opening_Direction);
            SetVisible(true, PUR_Shape_L, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Height_L, PUR_Length_L, PUR_Width_L, PUR_Internalcoating_L, PUR_Decoration_L, PUR_Opening_Direction_L);
            SetForeColor(Color.Blue, PUR_Shape_L, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Height_L, PUR_Length_L, PUR_Width_L, PUR_Internalcoating_L, PUR_Decoration_L, PUR_Opening_Direction_L);
            switch(PUR_Classification.SelectedValue)
            {
                case "":
                    SetVisible(false, PUR_Shape, PUR_Top_Diameter, PUR_Bottom_Diameter, PUR_Height, PUR_Length, PUR_Width, PUR_Internalcoating, PUR_Decoration, PUR_Opening_Direction);
                    SetVisible(false, PUR_Shape_L, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Height_L, PUR_Length_L, PUR_Width_L, PUR_Internalcoating_L, PUR_Decoration_L, PUR_Opening_Direction_L);
                    break;
                case "Holdingunit":
                    if (PUR_Shape.SelectedValue == "cylindrical")
                    {
                        SetVisible(false, PUR_Bottom_Diameter, PUR_Length, PUR_Width, PUR_Decoration, PUR_Opening_Direction);
                        SetVisible(false, PUR_Bottom_Diameter_L, PUR_Length_L, PUR_Width_L, PUR_Decoration_L, PUR_Opening_Direction_L);
                        SetForeColor(Color.Black , PUR_Bottom_Diameter_L, PUR_Length_L, PUR_Width_L, PUR_Decoration_L, PUR_Opening_Direction_L);
                    }
                    else if (PUR_Shape.SelectedValue == "recatangular normal")
                    {
                        SetVisible(false, PUR_Top_Diameter, PUR_Bottom_Diameter, PUR_Decoration, PUR_Opening_Direction);
                        SetVisible(false, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Decoration_L, PUR_Opening_Direction_L);
                        SetForeColor(Color.Black, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Decoration_L, PUR_Opening_Direction_L);
                    }
                    else
                    {
                        SetVisible(false, PUR_Length, PUR_Width, PUR_Decoration, PUR_Opening_Direction);
                        SetVisible(false, PUR_Length_L, PUR_Width_L, PUR_Decoration_L, PUR_Opening_Direction_L);
                        SetForeColor(Color.Black, PUR_Length_L, PUR_Width_L, PUR_Decoration_L, PUR_Opening_Direction_L);
                    }
                    break;

                case "Label":
                    SetVisible(false, PUR_Shape, PUR_Top_Diameter, PUR_Bottom_Diameter, PUR_Width, PUR_Internalcoating, PUR_Decoration, PUR_Internalcoating, PUR_Opening_Direction);
                    SetVisible(false, PUR_Shape_L, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Width_L, PUR_Internalcoating_L, PUR_Decoration_L, PUR_Internalcoating_L, PUR_Opening_Direction_L);
                    SetForeColor(Color.Black, PUR_Shape_L, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Width_L, PUR_Internalcoating_L, PUR_Decoration_L, PUR_Internalcoating_L, PUR_Opening_Direction_L);
                    break;

                case "Over pack":
                    SetVisible(false, PUR_Shape, PUR_Top_Diameter, PUR_Bottom_Diameter, PUR_Width, PUR_Internalcoating, PUR_Opening_Direction);
                    SetVisible(false, PUR_Shape_L, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Width_L, PUR_Internalcoating_L, PUR_Opening_Direction_L);
                    SetForeColor(Color.Black, PUR_Shape_L, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Width_L, PUR_Internalcoating_L, PUR_Opening_Direction_L);
                    break;
            }
        }
        #endregion

        #region 方法 InitControls(初始化)
        public void InitControls(mdc_Material mt)
        {
            //如果当前 Tabs 是隐藏的情况，退出
            Visible = IsUsed;
            if (!IsUsed)
            {
                return;
            }

            InitShowHide();

           // if (!IsLoaded)
           // {
                InitDropDownList();
           // }

            Distribute(mt);

            SetForeColor(Color.Black, PUR_Rounding_Value_L, PUR_Plant_L, PUR_Material_Group_L, PUR_Lab_Office_L, PUR_GenItemCatGroup_L, PUR_Base_Unit_Of_Measure_L, PUR_Division_L, PUR_Purchasing_Group_L, PUR_Source_List_L, PUR_Order_Unit_L, PUR_Gross_Weight_L, PUR_Net_Weight_L, PUR_Weight_Unit_L, PUR_Volume_L, PUR_Volume_Unit_L, PUR_Classification_L, PUR_Shape_L, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Height_L, PUR_Length_L, PUR_Width_L, PUR_Internalcoating_L, PUR_Decoration_L, PUR_Opening_Direction_L, PUR_PO_Price_L, PUR_Special_Procurement_L, PUR_Pack_Size_L, PUR_Minimum_Lot_Size_L, PUR_Fixed_Lot_Size_L, PUR_Rounding_Value_L, PUR_Maximum_Lot_Size_L, PUR_Planned_Deliv_Time_L);

            if (TaskAPI.IsAllowSubmit)
            {
                switch (Action)
                {
                    case "C":
                        SetEnable(true,PUR_Individual, PUR_Description_EN_1, PUR_Description_EN_2, PUR_Description_EN_3, PUR_Description_EN_4, PUR_Description_ZH_1, PUR_Description_ZH_2, PUR_Description_ZH_3, PUR_Description_ZH_4, PUR_Material_Group, PUR_Lab_Office, PUR_GenItemCatGroup, PUR_Base_Unit_Of_Measure, PUR_Division, PUR_Purchasing_Group, PUR_Source_List, PUR_Order_Unit, PUR_Gross_Weight, PUR_Net_Weight, PUR_Weight_Unit, PUR_Volume, PUR_Volume_Unit, PUR_Classification, PUR_Shape, PUR_Top_Diameter, PUR_Bottom_Diameter, PUR_Height, PUR_Length, PUR_Width, PUR_Internalcoating, PUR_Decoration, PUR_Opening_Direction, PUR_PO_Price, PUR_Special_Procurement, PUR_Pack_Size, PUR_Minimum_Lot_Size, PUR_Fixed_Lot_Size, PUR_Rounding_Value, PUR_Maximum_Lot_Size, PUR_Planned_Deliv_Time);
                        SetEnable(true, PUR_Plant, PUR_Storage_Location, PUR_Plant_sp_matl, PUR_ABC_Indicator, PUR_MRP_Type, PUR_MRP_Controller, PUR_Lot_Size, PUR_Procurement_type, PUR_Backflush, PUR_Prod_ocation, PUR_SchedMargin_key, PUR_Storage_locForEP, PUR_Stock_det_grp, PUR_Safty_Stock, PUR_Safety_time_ind, PUR_Availability_check, PUR_Safety_time_actcov, PUR_Period_Indicator);

                        SetForeColor(Color.Blue, PUR_Description_EN_L_0, PUR_Description_EN_0, PUR_Material_Group_L, PUR_Lab_Office_L, PUR_PO_Price_L, PUR_Special_Procurement_L, PUR_Pack_Size_L);
                         
                        if (Category == "PACK" && Action == "C" && TaskAPI.Process != "NPL Master Data Application")
                        {
                            SetForeColor(Color.Blue, PUR_PO_Price_L);
                        }
                        else if (TaskAPI.Process == "PKG RAW Code Application" && Action == "C")
                        {
                            SetForeColor(Color.Blue, PUR_PO_Price_L);
                        }
                        else
                        {
                            SetForeColor(Color.Black, PUR_PO_Price_L);
                        }
                        if (Category == "FINI" && TaskAPI.Process == "TW New Raw Material Creation")
                        {
                            SetForeColor(Color.Blue, PUR_Plant_L, PUR_PO_Price_L,   PUR_Special_Procurement_L,  PUR_ABC_Indicator_L, PUR_Planned_Deliv_Time_L);
                        }
                        SetDefaultValue();
                        break;
                    case "S": 
                        SetEnable(false, PUR_Description_EN_1, PUR_Description_EN_2, PUR_Description_EN_3, PUR_Description_EN_4, PUR_Description_ZH_1, PUR_Description_ZH_2, PUR_Description_ZH_3, PUR_Description_ZH_4, PUR_Material_Group, PUR_Lab_Office, PUR_GenItemCatGroup, PUR_Base_Unit_Of_Measure, PUR_Division, PUR_Purchasing_Group, PUR_Source_List, PUR_Order_Unit, PUR_Gross_Weight, PUR_Net_Weight, PUR_Weight_Unit, PUR_Volume, PUR_Volume_Unit, PUR_Classification, PUR_Shape, PUR_Top_Diameter, PUR_Bottom_Diameter, PUR_Height, PUR_Length, PUR_Width, PUR_Internalcoating, PUR_Decoration, PUR_Opening_Direction, PUR_PO_Price, PUR_Special_Procurement, PUR_Pack_Size, PUR_Minimum_Lot_Size, PUR_Fixed_Lot_Size, PUR_Rounding_Value, PUR_Maximum_Lot_Size, PUR_Planned_Deliv_Time);
                        SetEnable(false, PUR_Plant, PUR_Storage_Location, PUR_Plant_sp_matl, PUR_ABC_Indicator, PUR_MRP_Type, PUR_MRP_Controller, PUR_Lot_Size, PUR_Procurement_type, PUR_Backflush, PUR_Prod_ocation, PUR_SchedMargin_key, PUR_Storage_locForEP, PUR_Stock_det_grp, PUR_Safty_Stock, PUR_Safety_time_ind, PUR_Availability_check, PUR_Safety_time_actcov, PUR_Period_Indicator, PUR_Issdate, PUR_Exemption);
                        SetDefaultValue();
                        if (Category == "FINI" && TaskAPI.Process == "TW New Raw Material Creation")
                        {   
                            SetForeColor(Color.Black, PUR_PO_Price_L,PUR_Material_Group_L, PUR_Lab_Office_L, PUR_Special_Procurement_L, PUR_Storage_Location_L, PUR_ABC_Indicator_L, PUR_Planned_Deliv_Time_L, PUR_Availability_check_L);
                        }
                        SetForeColor(Color.Black, PUR_Rounding_Value_L, PUR_Plant_L, PUR_Material_Group_L, PUR_Lab_Office_L, PUR_GenItemCatGroup_L, PUR_Base_Unit_Of_Measure_L, PUR_Division_L, PUR_Purchasing_Group_L, PUR_Source_List_L, PUR_Order_Unit_L, PUR_Gross_Weight_L, PUR_Net_Weight_L, PUR_Weight_Unit_L, PUR_Volume_L, PUR_Volume_Unit_L, PUR_Classification_L, PUR_Shape_L, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Height_L, PUR_Length_L, PUR_Width_L, PUR_Internalcoating_L, PUR_Decoration_L, PUR_Opening_Direction_L, PUR_PO_Price_L, PUR_Special_Procurement_L, PUR_Pack_Size_L, PUR_Minimum_Lot_Size_L, PUR_Fixed_Lot_Size_L, PUR_Rounding_Value_L, PUR_Maximum_Lot_Size_L, PUR_Planned_Deliv_Time_L, PUR_Issdate_L, PUR_Exemption_L);

                        break;
                    case "E":
                        SetEnable(true, PUR_Plant, PUR_Plant_L, PUR_Storage_Location, PUR_Storage_Location_L, PUR_Plant_sp_matl, PUR_Plant_sp_matl_L, PUR_ABC_Indicator, PUR_ABC_Indicator_L, PUR_MRP_Type, PUR_MRP_Type_L, PUR_MRP_Controller, PUR_MRP_Controller_L, PUR_Lot_Size, PUR_Lot_Size_L, PUR_Procurement_type, PUR_Procurement_type_L, PUR_Backflush, PUR_Backflush_L, PUR_Prod_ocation, PUR_Prod_ocation_L, PUR_SchedMargin_key, PUR_SchedMargin_key_L, PUR_Storage_locForEP, PUR_Storage_locForEP_L, PUR_Stock_det_grp, PUR_Stock_det_grp_L, PUR_Safty_Stock, PUR_Safty_Stock_L, PUR_Safety_time_ind, PUR_Safety_time_ind_L, PUR_Availability_check, PUR_Availability_check_L, PUR_Safety_time_actcov, PUR_Safety_time_actcov_L, PUR_Period_Indicator, PUR_Period_Indicator_L);
                        if (Category == "FINI" && TaskAPI.Process == "TW New Raw Material Creation")
                        {
                            SetForeColor(Color.Black, PUR_PO_Price_L,PUR_Material_Group_L, PUR_Lab_Office_L, PUR_Special_Procurement_L, PUR_Storage_Location_L, PUR_ABC_Indicator_L, PUR_Planned_Deliv_Time_L, PUR_Availability_check_L);
                        }
                        SetEnable(true, PUR_Description_EN_1, PUR_Description_EN_2, PUR_Description_EN_3, PUR_Description_EN_4, PUR_Description_ZH_1, PUR_Description_ZH_2, PUR_Description_ZH_3, PUR_Description_ZH_4, PUR_Material_Group, PUR_Lab_Office, PUR_GenItemCatGroup, PUR_Base_Unit_Of_Measure, PUR_Division, PUR_Purchasing_Group, PUR_Source_List, PUR_Order_Unit, PUR_Gross_Weight, PUR_Net_Weight, PUR_Weight_Unit, PUR_Volume, PUR_Volume_Unit, PUR_Classification, PUR_Shape, PUR_Top_Diameter, PUR_Bottom_Diameter, PUR_Height, PUR_Length, PUR_Width, PUR_Internalcoating, PUR_Decoration, PUR_Opening_Direction, PUR_PO_Price, PUR_Special_Procurement, PUR_Pack_Size, PUR_Minimum_Lot_Size, PUR_Fixed_Lot_Size, PUR_Rounding_Value, PUR_Maximum_Lot_Size, PUR_Planned_Deliv_Time, PUR_Issdate, PUR_Exemption);
                        SetForeColor(Color.Black, PUR_Rounding_Value_L, PUR_Plant_L, PUR_Material_Group_L, PUR_Lab_Office_L, PUR_GenItemCatGroup_L, PUR_Base_Unit_Of_Measure_L, PUR_Division_L, PUR_Purchasing_Group_L, PUR_Source_List_L, PUR_Order_Unit_L, PUR_Gross_Weight_L, PUR_Net_Weight_L, PUR_Weight_Unit_L, PUR_Volume_L, PUR_Volume_Unit_L, PUR_Classification_L, PUR_Shape_L, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Height_L, PUR_Length_L, PUR_Width_L, PUR_Internalcoating_L, PUR_Decoration_L, PUR_Opening_Direction_L, PUR_PO_Price_L, PUR_Special_Procurement_L, PUR_Pack_Size_L, PUR_Minimum_Lot_Size_L, PUR_Fixed_Lot_Size_L, PUR_Rounding_Value_L, PUR_Maximum_Lot_Size_L, PUR_Planned_Deliv_Time_L, PUR_Issdate_L, PUR_Exemption_L);
                        SetDefaultValue();
                        break;
                }
            }
            else
            {
                SetEnable(false, PUR_Plant, PUR_Storage_Location, PUR_Plant_sp_matl, PUR_ABC_Indicator,  PUR_MRP_Type,  PUR_MRP_Controller,  PUR_Lot_Size,  PUR_Procurement_type,  PUR_Backflush,  PUR_Prod_ocation,  PUR_SchedMargin_key,  PUR_Storage_locForEP,  PUR_Stock_det_grp,  PUR_Safty_Stock,  PUR_Safety_time_ind,  PUR_Availability_check,  PUR_Safety_time_actcov,  PUR_Period_Indicator);

                SetEnable(false,PUR_PO_Price, PUR_Description_EN_1, PUR_Description_EN_2, PUR_Description_EN_3, PUR_Description_EN_4, PUR_Description_ZH_1, PUR_Description_ZH_2, PUR_Description_ZH_3, PUR_Description_ZH_4, PUR_Material_Group, PUR_Lab_Office, PUR_GenItemCatGroup, PUR_Base_Unit_Of_Measure, PUR_Division, PUR_Purchasing_Group, PUR_Source_List, PUR_Order_Unit, PUR_Gross_Weight, PUR_Net_Weight, PUR_Weight_Unit, PUR_Volume, PUR_Volume_Unit, PUR_Classification, PUR_Shape, PUR_Top_Diameter, PUR_Bottom_Diameter, PUR_Height, PUR_Length, PUR_Width, PUR_Internalcoating, PUR_Decoration, PUR_Opening_Direction, PUR_PO_Price, PUR_Special_Procurement, PUR_Pack_Size, PUR_Minimum_Lot_Size, PUR_Fixed_Lot_Size, PUR_Rounding_Value, PUR_Maximum_Lot_Size, PUR_Planned_Deliv_Time);
            }

            //魏军添加 控制dropdownlist的enable属性
            string item = null;
            string value = null;
            bool flag_2 = false;
            foreach (Control cr in this.Controls)
            {
                if (cr is DropDownList)
                {
                    DropDownList tb = (DropDownList)cr;
                    if (!tb.Enabled)
                    {
                        
                        try
                        {
                            item = tb.SelectedItem.Text;
                            value = tb.SelectedValue.ToString();
                        }
                        catch (Exception)
                        {
                            flag_2 = true;

                        }
                        if (!flag_2)
                        {
                            tb.Enabled = true;
                            tb.Items.Clear();
                            tb.Items.Add(new ListItem(item, value));
                            tb.SelectedIndex = 0;
                            tb.ForeColor = System.Drawing.Color.DimGray;
                        }
                    }

                }
            }

        }
        #endregion

        #region 方法 InitDropdownList(初始化下拉框数据源)
        private void InitDropDownList()
        {
            PUR_Plant.Items.Clear();
            PUR_Plant.Items.Add(new ListItem("", ""));
            IList<m_Plant> dlts = (m_Plant.status == 1 & m_Plant.categary == "P").List<m_Plant>();
            foreach (m_Plant dlt in dlts)
            {
                PUR_Plant.Items.Add(new ListItem(dlt.PlantName, dlt.PlantName));
            }
            if (FORM == "FORM-TW-003")
            {
                PUR_Plant.Items.Clear();
                PUR_Plant.Items.Add(new ListItem("", ""));
                PUR_Plant.Items.Add(new ListItem("KT1P", "KT1P"));
                PUR_Plant.Items.Add(new ListItem("KT2P", "KT2P"));
            }
        }
        #endregion

        #region 方法 InitShowHide(初始化控件显示)
        private void InitShowHide()
        {
            #region 设置禁启用
            SetVisible(false, PUR_Description_EN_1, PUR_Description_EN_2, PUR_Description_EN_3, PUR_Description_EN_4, PUR_Description_ZH_1, PUR_Description_ZH_2, PUR_Description_ZH_3, PUR_Description_ZH_4, PUR_Material_Group, PUR_Lab_Office, PUR_GenItemCatGroup, PUR_Base_Unit_Of_Measure, PUR_Division, PUR_Purchasing_Group, PUR_Source_List, PUR_Order_Unit, PUR_Gross_Weight, PUR_Net_Weight, PUR_Weight_Unit, PUR_Volume, PUR_Volume_Unit, PUR_Classification, PUR_Shape, PUR_Top_Diameter, PUR_Bottom_Diameter, PUR_Height, PUR_Length, PUR_Width, PUR_Internalcoating, PUR_Decoration, PUR_Opening_Direction, PUR_PO_Price, PUR_Special_Procurement, PUR_Pack_Size, PUR_Minimum_Lot_Size, PUR_Fixed_Lot_Size, PUR_Rounding_Value, PUR_Maximum_Lot_Size, PUR_Planned_Deliv_Time
                            , PUR_Description_EN_0, PUR_Description_ZH_0, PUR_Description_EN_L_0, PUR_Description_EN_L_1, PUR_Description_EN_L_2, PUR_Description_EN_L_3, PUR_Description_EN_L_4, PUR_Description, PUR_Material_Group_L, PUR_Lab_Office_L, PUR_GenItemCatGroup_L, PUR_Base_Unit_Of_Measure_L, PUR_Division_L, PUR_Purchasing_Group_L, PUR_Source_List_L, PUR_Order_Unit_L, PUR_Gross_Weight_L, PUR_Net_Weight_L, PUR_Weight_Unit_L, PUR_Volume_L, PUR_Volume_Unit_L, PUR_Classification_L, PUR_Shape_L, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Height_L, PUR_Length_L, PUR_Width_L, PUR_Internalcoating_L, PUR_Decoration_L, PUR_Opening_Direction_L, PUR_PO_Price_L, PUR_Special_Procurement_L, PUR_Pack_Size_L, PUR_Minimum_Lot_Size_L, PUR_Fixed_Lot_Size_L
                            , PUR_Issdate,PUR_Issdate_L,PUR_Exemption,PUR_Exemption_L,PUR_Rounding_Value_L, PUR_Maximum_Lot_Size_L, PUR_Planned_Deliv_Time_L, PUR_Planned_Deliv_Time_L_2, PUR_P1, PUR_Individual_L, PUR_Individual);
            SetVisible(false, PUR_Plant, PUR_Plant_L, PUR_Storage_Location, PUR_Storage_Location_L, PUR_Plant_sp_matl, PUR_Plant_sp_matl_L, PUR_ABC_Indicator, PUR_ABC_Indicator_L, PUR_MRP_Type, PUR_MRP_Type_L, PUR_MRP_Controller, PUR_MRP_Controller_L, PUR_Lot_Size, PUR_Lot_Size_L, PUR_Procurement_type, PUR_Procurement_type_L, PUR_Backflush, PUR_Backflush_L, PUR_Prod_ocation, PUR_Prod_ocation_L, PUR_SchedMargin_key, PUR_SchedMargin_key_L, PUR_Storage_locForEP, PUR_Storage_locForEP_L, PUR_Stock_det_grp, PUR_Stock_det_grp_L, PUR_Safty_Stock, PUR_Safty_Stock_L, PUR_Safety_time_ind, PUR_Safety_time_ind_L, PUR_Availability_check, PUR_Availability_check_L, PUR_Safety_time_actcov, PUR_Safety_time_actcov_L, PUR_Period_Indicator, PUR_Period_Indicator_L);
            switch (FORM)
            {
                case "FORM-002":
                    if (Category == "LID")
                    {
                        SetVisible(true, PUR_Description_EN_1, PUR_Description_EN_2, PUR_Description_EN_3, PUR_Description_EN_4, PUR_Description_ZH_1, PUR_Description_ZH_2, PUR_Description_ZH_3, PUR_Description_ZH_4, PUR_Material_Group, PUR_Lab_Office, PUR_GenItemCatGroup, PUR_Base_Unit_Of_Measure, PUR_Division, PUR_Purchasing_Group, PUR_Source_List, PUR_Order_Unit, PUR_Gross_Weight, PUR_Net_Weight, PUR_Weight_Unit, PUR_Volume, PUR_Volume_Unit, PUR_Classification, PUR_Shape, PUR_Top_Diameter, PUR_Bottom_Diameter, PUR_Height, PUR_Length, PUR_Width, PUR_Internalcoating, PUR_Decoration, PUR_Opening_Direction
                                       ,  PUR_Description_EN_0, PUR_Description_ZH_0, PUR_Description_EN_L_0, PUR_Description_EN_L_1, PUR_Description_EN_L_2, PUR_Description_EN_L_3, PUR_Description_EN_L_4, PUR_Description, PUR_Material_Group_L, PUR_Lab_Office_L, PUR_GenItemCatGroup_L, PUR_Base_Unit_Of_Measure_L, PUR_Division_L, PUR_Purchasing_Group_L, PUR_Source_List_L, PUR_Order_Unit_L, PUR_Gross_Weight_L, PUR_Net_Weight_L, PUR_Weight_Unit_L, PUR_Volume_L, PUR_Volume_Unit_L, PUR_Classification_L, PUR_Shape_L, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Height_L, PUR_Length_L, PUR_Width_L, PUR_Internalcoating_L, PUR_Decoration_L, PUR_Opening_Direction_L, PUR_P1);
                    }
                    else
                    {
                        SetVisible(true, PUR_Purchasing_Group, PUR_Source_List, PUR_Order_Unit, PUR_Gross_Weight, PUR_Net_Weight, PUR_Weight_Unit, PUR_Volume, PUR_Volume_Unit, PUR_Classification, PUR_Shape, PUR_Top_Diameter, PUR_Bottom_Diameter, PUR_Height, PUR_Length, PUR_Width, PUR_Internalcoating, PUR_Decoration, PUR_Opening_Direction, PUR_PO_Price
                                       , PUR_Purchasing_Group_L, PUR_Source_List_L, PUR_Order_Unit_L, PUR_Gross_Weight_L, PUR_Net_Weight_L, PUR_Weight_Unit_L, PUR_Volume_L, PUR_Volume_Unit_L, PUR_Classification_L, PUR_Shape_L, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Height_L, PUR_Length_L, PUR_Width_L, PUR_Internalcoating_L, PUR_Decoration_L, PUR_Opening_Direction_L, PUR_PO_Price_L);
                    }

                    if (Category == "PACK")
                    {
                        SetVisible(true, PUR_Issdate, PUR_Issdate_L, PUR_Exemption, PUR_Exemption_L);
                        SetVisible(false, PUR_Gross_Weight_L, PUR_Gross_Weight, PUR_Weight_Unit_L, PUR_Weight_Unit, PUR_Net_Weight_L, PUR_Net_Weight, PUR_Volume_Unit_L, PUR_Volume_Unit, PUR_Volume_L, PUR_Volume);
                    }
                    break;
                case "FORM-009":
                    SetVisible(true, PUR_Purchasing_Group, PUR_Source_List, PUR_Order_Unit, PUR_Gross_Weight, PUR_PO_Price, PUR_Special_Procurement, PUR_Pack_Size, PUR_Minimum_Lot_Size, PUR_Fixed_Lot_Size, PUR_Rounding_Value, PUR_Maximum_Lot_Size, PUR_Planned_Deliv_Time
                                   , PUR_Purchasing_Group_L, PUR_Source_List_L, PUR_Order_Unit_L, PUR_Gross_Weight_L, PUR_PO_Price_L, PUR_Special_Procurement_L, PUR_Pack_Size_L, PUR_Minimum_Lot_Size_L, PUR_Fixed_Lot_Size_L, PUR_Rounding_Value_L, PUR_Maximum_Lot_Size_L, PUR_Planned_Deliv_Time_L, PUR_Planned_Deliv_Time_L_2);

                    if (Category == "RAW")
                    {
                        SetVisible(false, PUR_Gross_Weight_L, PUR_Gross_Weight);
                    }
                    break;
                case "FORM-036":
                    PUR_Title.Text = "&nbsp;";
                    SetVisible(true, PUR_Purchasing_Group, PUR_Source_List, PUR_PO_Price, PUR_Special_Procurement, PUR_Pack_Size, PUR_Order_Unit
                                   , PUR_Purchasing_Group_L, PUR_Source_List_L, PUR_PO_Price_L, PUR_Special_Procurement_L, PUR_Pack_Size_L, PUR_Order_Unit_L);
                    break;
                case "FORM-043":
                    PUR_Title.Text = "&nbsp;";
                    SetVisible(true, PUR_Purchasing_Group, PUR_Source_List, PUR_PO_Price, PUR_Order_Unit, PUR_Gross_Weight, PUR_Net_Weight, PUR_Weight_Unit, PUR_Volume, PUR_Volume_Unit, PUR_Classification, PUR_Shape, PUR_Top_Diameter, PUR_Bottom_Diameter, PUR_Height, PUR_Length, PUR_Length, PUR_Width, PUR_Internalcoating, PUR_Decoration, PUR_Opening_Direction
                                   , PUR_Purchasing_Group_L, PUR_Source_List_L, PUR_PO_Price_L, PUR_Order_Unit_L, PUR_Gross_Weight_L, PUR_Net_Weight_L, PUR_Weight_Unit_L, PUR_Volume_L, PUR_Volume_Unit_L, PUR_Classification_L, PUR_Shape_L, PUR_Top_Diameter_L, PUR_Bottom_Diameter_L, PUR_Height_L, PUR_Length_L, PUR_Length_L, PUR_Width_L, PUR_Internalcoating_L, PUR_Decoration_L, PUR_Opening_Direction_L);
                    break;
                case "FORM-015":
                    PUR_Title.Text = "&nbsp;";
                    SetVisible(true, PUR_Purchasing_Group, PUR_Purchasing_Group_L);
                    break;
                case "FORM-TW-003":
                   
                    SetVisible(true,PUR_PO_Price, PUR_Purchasing_Group, PUR_Purchasing_Group_L, PUR_Source_List, PUR_Source_List_L, PUR_Maximum_Lot_Size_L, PUR_Maximum_Lot_Size, PUR_Minimum_Lot_Size_L, PUR_Minimum_Lot_Size, PUR_Special_Procurement_L, PUR_Special_Procurement, PUR_Rounding_Value_L, PUR_Rounding_Value, PUR_Planned_Deliv_Time_L, PUR_Planned_Deliv_Time);
                    //SetVisible(true,  PUR_Plant_L,  PUR_Storage_Location_L,  PUR_Plant_sp_matl_L,  PUR_ABC_Indicator_L,  PUR_MRP_Type_L,  PUR_MRP_Controller_L,  PUR_Lot_Size_L,  PUR_Procurement_type_L,  PUR_Backflush_L,  PUR_Prod_ocation_L,  PUR_SchedMargin_key_L,  PUR_Storage_locForEP_L,  PUR_Stock_det_grp_L,  PUR_Safty_Stock_L,  PUR_Safety_time_ind_L,  PUR_Availability_check_L,  PUR_Safety_time_actcov_L,  PUR_Period_Indicator_L);
                    //SetVisible(true, PUR_Plant, PUR_Storage_Location, PUR_Plant_sp_matl, PUR_ABC_Indicator, PUR_MRP_Type, PUR_MRP_Controller, PUR_Lot_Size, PUR_Procurement_type, PUR_Backflush, PUR_Prod_ocation, PUR_SchedMargin_key, PUR_Storage_locForEP, PUR_Stock_det_grp, PUR_Safty_Stock, PUR_Safety_time_ind, PUR_Availability_check, PUR_Safety_time_actcov, PUR_Period_Indicator);
                    SetVisible(true, PUR_Individual, PUR_Individual_L,PUR_PO_Price_L, PUR_Plant, PUR_Plant_L, PUR_Plant_sp_matl, PUR_Plant_sp_matl_L, PUR_ABC_Indicator, PUR_ABC_Indicator_L, PUR_MRP_Type, PUR_MRP_Type_L, PUR_MRP_Controller, PUR_MRP_Controller_L, PUR_Lot_Size, PUR_Lot_Size_L, PUR_Procurement_type, PUR_Procurement_type_L, PUR_Backflush, PUR_Backflush_L, PUR_Prod_ocation, PUR_Prod_ocation_L, PUR_SchedMargin_key, PUR_SchedMargin_key_L, PUR_Storage_locForEP, PUR_Storage_locForEP_L, PUR_Stock_det_grp, PUR_Stock_det_grp_L, PUR_Safty_Stock, PUR_Safty_Stock_L, PUR_Safety_time_ind, PUR_Safety_time_ind_L, PUR_Availability_check, PUR_Availability_check_L, PUR_Safety_time_actcov, PUR_Safety_time_actcov_L, PUR_Period_Indicator, PUR_Period_Indicator_L);
                    break;

                case "FORM-TW-007":
                    SetVisible(true, PUR_Minimum_Lot_Size_L, PUR_Minimum_Lot_Size, PUR_Rounding_Value_L, PUR_Rounding_Value, PUR_Planned_Deliv_Time_L, PUR_Planned_Deliv_Time);
                    break;
            }

            SetToolTip();
            #endregion
        }
        #endregion

        #region 方法 Distribute,Collect(分发, 收集值)
        public void Distribute(mdc_Material mt)
        {
            //如果当前 Tabs 是隐藏的情况，退出
            if (!IsUsed)
            {
                return;
            }
            if (((Parent as TabMaterial).Status.FORM == "FORM-009" || (Parent as TabMaterial).Status.FORM == "FORM-036") && PUR_Special_Procurement.SelectedValue == "10")
            {
                (Page as PMDC).TabMaterial1.Planning1.PLA_Stock_Det_Grp.Text = "0001";
                SetEnable(false, (Page as PMDC).TabMaterial1.Planning1.PLA_Stock_Det_Grp);
                SetForeColor(Color.Orange, (Page as PMDC).TabMaterial1.Planning1.PLA_Stock_Det_Grp_L);
            }

            PUR_Description_EN_1.Text               = mt.PUR_Description_EN_1;
            PUR_Description_EN_2.Text               = mt.PUR_Description_EN_2;
            PUR_Description_EN_3.SelectedValue      = mt.PUR_Description_EN_3;
            PUR_Description_EN_4.Text               = mt.PUR_Description_EN_4;
            PUR_Description_ZH_1.Text               = mt.PUR_Description_ZH_1;
            PUR_Description_ZH_2.Text               = mt.PUR_Description_ZH_2;
            PUR_Description_ZH_3.SelectedValue      = mt.PUR_Description_ZH_3;
            PUR_Description_ZH_4.Text               = mt.PUR_Description_ZH_4;
            PUR_Material_Group.Text                 = mt.PUR_Material_Group;
            PUR_Lab_Office.SelectedValue            = mt.PUR_Lab_Office;
            PUR_GenItemCatGroup.Text                = mt.PUR_GenItemCatGroup;
            PUR_Base_Unit_Of_Measure.Text           = mt.PUR_Base_Unit_Of_Measure;
            PUR_Division.Text                       = mt.PUR_Division;
            PUR_Purchasing_Group.Text               = mt.PUR_Purchasing_Group;
            PUR_Source_List.Checked                 = mt.PUR_Source_List == "1";
            PUR_Order_Unit.Text                     = mt.PUR_Order_Unit;
            PUR_Gross_Weight.Text                   = mt.PUR_Gross_Weight;
            PUR_Net_Weight.Text                     = mt.PUR_Net_Weight;
            PUR_Weight_Unit.Text                    = mt.PUR_Weight_Unit;
            PUR_Volume.Text                         = mt.PUR_Volume;
            PUR_Volume_Unit.Text                    = mt.PUR_Volume_Unit;
            PUR_Classification.SelectedValue        = mt.PUR_Classification;
            PUR_Shape.SelectedValue                 = mt.PUR_Shape;
            PUR_Top_Diameter.Text                   = mt.PUR_Top_Diameter;
            PUR_Bottom_Diameter.Text                = mt.PUR_Bottom_Diameter;
            PUR_Height.Text                         = mt.PUR_Height;
            PUR_Length.Text                         = mt.PUR_Length;
            PUR_Width.Text                          = mt.PUR_Width;
            PUR_Internalcoating.Text                = mt.PUR_Internalcoating;
            PUR_Decoration.Text                     = mt.PUR_Decoration;
            PUR_Opening_Direction.Text              = mt.PUR_Opening_Direction;
            PUR_PO_Price.Text                       = mt.PUR_PO_Price;
            PUR_Special_Procurement.SelectedValue   = mt.PUR_Special_Procurement;
            PUR_Pack_Size.Text                      = mt.PUR_Pack_Size;
            PUR_Minimum_Lot_Size.Text               = mt.PUR_Minimum_Lot_Size;
            PUR_Fixed_Lot_Size.Text                 = mt.PUR_Fixed_Lot_Size;
            PUR_Rounding_Value.Text                 = mt.PUR_Rounding_Value;
            PUR_Maximum_Lot_Size.Text               = mt.PUR_Maximum_Lot_Size;
            PUR_Planned_Deliv_Time.Text             = mt.PUR_Planned_Deliv_Time;

            PUR_Plant.SelectedValue = mt.PUR_Plant;
            PUR_Storage_Location.Text = mt.PUR_Storage_Location;
            PUR_Plant_sp_matl.Text = mt.PUR_Plant_sp_matl;
            PUR_ABC_Indicator.Text = mt.PUR_ABC_Indicator;
            PUR_MRP_Type.Text = mt.PUR_MRP_Type;
            PUR_MRP_Controller.Text = mt.PUR_MRP_Controller;
            PUR_Lot_Size.Text = mt.PUR_Lot_Size;
            PUR_Procurement_type.Text = mt.PUR_Procurement_type;
            PUR_Backflush.Text = mt.PUR_Backflush;
            PUR_Prod_ocation.Text = mt.PUR_Prod_ocation;
            PUR_SchedMargin_key.Text = mt.PUR_SchedMargin_key;
            PUR_Storage_locForEP.Text = mt.PUR_Storage_locForEP;
            PUR_Stock_det_grp.Text = mt.PUR_Stock_det_grp;
            PUR_Safty_Stock.Text = mt.PUR_Safty_Stock;
            PUR_Safety_time_ind.Text = mt.PUR_Safety_time_ind;
            PUR_Availability_check.Text = mt.PUR_Availability_check;
            PUR_Safety_time_actcov.Text = mt.PUR_Safety_time_actcov;
            PUR_Period_Indicator.Text = mt.PUR_Period_Indicator;
            PUR_Individual.Text = mt.PUR_Individual;

            PUR_Issdate.Text = mt.PUR_Issdate;
            PUR_Exemption.Text = mt.PUR_Exemption;
            //Planning 部门当 Lot Size 等于FX时，Purchasing 的 Fixed Lot Size 必填
            switch (Category)
            {
                case "RAW":
                case "PACK":
                    if (!string.IsNullOrEmpty(mt.PLA_Lot_Size) && mt.PLA_Lot_Size.StartsWith("FX"))
                    {
                        SetForeColor(Color.Blue, PUR_Fixed_Lot_Size_L);
                    }
                    break;
            }
        }

        public void Collect(ref mdc_Material mt)
        {
            //如果当前 Tabs 是隐藏的情况，退出
            if (!IsUsed)
            {
                return;
            }

            mt.PUR_Description_EN_1     = PUR_Description_EN_1.Text;              
            mt.PUR_Description_EN_2     = PUR_Description_EN_2.Text;              
            mt.PUR_Description_EN_3     = PUR_Description_EN_3.SelectedValue;     
            mt.PUR_Description_EN_4     = PUR_Description_EN_4.Text;              
            mt.PUR_Description_ZH_1     = PUR_Description_ZH_1.Text;              
            mt.PUR_Description_ZH_2     = PUR_Description_ZH_2.Text;              
            mt.PUR_Description_ZH_3     = PUR_Description_ZH_3.SelectedValue;     
            mt.PUR_Description_ZH_4     = PUR_Description_ZH_4.Text;              
            mt.PUR_Material_Group       = PUR_Material_Group.Text;                
            mt.PUR_Lab_Office           = PUR_Lab_Office.SelectedValue;           
            mt.PUR_GenItemCatGroup      = PUR_GenItemCatGroup.Text;              
            mt.PUR_Base_Unit_Of_Measure = PUR_Base_Unit_Of_Measure.Text;          
            mt.PUR_Division             = PUR_Division.Text;                      
            mt.PUR_Purchasing_Group     = PUR_Purchasing_Group.Text;              
            mt.PUR_Source_List          = PUR_Source_List.Checked ? "1" : "0";                
            mt.PUR_Order_Unit           = PUR_Order_Unit.Text;                    
            mt.PUR_Gross_Weight         = PUR_Gross_Weight.Text;                  
            mt.PUR_Net_Weight           = PUR_Net_Weight.Text;                    
            mt.PUR_Weight_Unit          = PUR_Weight_Unit.Text;                   
            mt.PUR_Volume               = PUR_Volume.Text;                        
            mt.PUR_Volume_Unit          = PUR_Volume_Unit.Text;                   
            mt.PUR_Classification       = PUR_Classification.SelectedValue;       
            mt.PUR_Shape                = PUR_Shape.SelectedValue;                
            mt.PUR_Top_Diameter         = PUR_Top_Diameter.Text;                  
            mt.PUR_Bottom_Diameter      = PUR_Bottom_Diameter.Text;               
            mt.PUR_Height               = PUR_Height.Text;                        
            mt.PUR_Length               = PUR_Length.Text;                        
            mt.PUR_Width                = PUR_Width.Text;                         
            mt.PUR_Internalcoating      = PUR_Internalcoating.Text;               
            mt.PUR_Decoration           = PUR_Decoration.Text;                    
            mt.PUR_Opening_Direction    = PUR_Opening_Direction.Text;             
            mt.PUR_PO_Price             = PUR_PO_Price.Text;                      
            mt.PUR_Special_Procurement  = PUR_Special_Procurement.SelectedValue;  
            mt.PUR_Pack_Size            = PUR_Pack_Size.Text;                     
            mt.PUR_Minimum_Lot_Size     = PUR_Minimum_Lot_Size.Text;              
            mt.PUR_Fixed_Lot_Size       = PUR_Fixed_Lot_Size.Text;                
            mt.PUR_Rounding_Value       = PUR_Rounding_Value.Text;                
            mt.PUR_Maximum_Lot_Size     = PUR_Maximum_Lot_Size.Text;              
            mt.PUR_Planned_Deliv_Time   = PUR_Planned_Deliv_Time.Text;


            mt.PUR_Plant                = PUR_Plant.SelectedValue;
            mt.PUR_Storage_Location     = PUR_Storage_Location.Text;
            mt.PUR_Plant_sp_matl        = PUR_Plant_sp_matl.Text;
            mt.PUR_ABC_Indicator        = PUR_ABC_Indicator.Text;
            mt.PUR_MRP_Type             = PUR_MRP_Type.Text;
            mt.PUR_MRP_Controller       = PUR_MRP_Controller.Text;
            mt.PUR_Lot_Size             = PUR_Lot_Size.Text;
            mt.PUR_Procurement_type     = PUR_Procurement_type.Text;
            mt.PUR_Backflush            = PUR_Backflush.Text;
            mt.PUR_Prod_ocation         = PUR_Prod_ocation.Text;
            mt.PUR_SchedMargin_key      = PUR_SchedMargin_key.Text;
            mt.PUR_Storage_locForEP     = PUR_Storage_locForEP.Text;
            mt.PUR_Stock_det_grp        = PUR_Stock_det_grp.Text;
            mt.PUR_Safty_Stock          = PUR_Safty_Stock.Text;
            mt.PUR_Safety_time_ind      = PUR_Safety_time_ind.Text;
            mt.PUR_Availability_check   = PUR_Availability_check.Text;
            mt.PUR_Safety_time_actcov   = PUR_Safety_time_actcov.Text;
            mt.PUR_Period_Indicator     = PUR_Period_Indicator.Text;
            mt.PUR_Individual = PUR_Individual.Text;
            mt.PUR_Issdate = PUR_Issdate.Text;
            mt.PUR_Exemption = PUR_Exemption.Text;
            ////Purchasing 里的 Stock det Grp 为10时，Planning 的 Storage Loc For EP 为 0001， 其他的情况为空值
            //mt.PLA_Storage_Loc_For_EP   = mt.PLA_Stock_Det_Grp
        }
        #endregion

        #region 方法 SetDefaultValue(设置默认值, 并禁用输入)
        public void SetDefaultValue()
        {
            switch(Category)
            {
                case "RAW":
                    PUR_Purchasing_Group.Text     = "K01, Raw Materials";
                    PUR_Source_List.Checked       = true;
                    SetEnable(false, PUR_Purchasing_Group, PUR_Source_List);
                    SetForeColor(Color.Orange, PUR_Purchasing_Group_L, PUR_Source_List_L);
                    break;
                case "PACK":
                    PUR_Base_Unit_Of_Measure.Text = "PC";
                    PUR_Division.Text             = "10";
                    PUR_GenItemCatGroup.Text      = "NORM";
                    PUR_Purchasing_Group.Text     = "K02, Pack Materials";
                    PUR_Source_List.Checked       = true;
                    PUR_Weight_Unit.Text          = "KG";
                    PUR_Volume_Unit.Text          = "L";
                    SetEnable(false, PUR_Base_Unit_Of_Measure, PUR_Division, PUR_GenItemCatGroup, PUR_Source_List, PUR_Purchasing_Group, PUR_Weight_Unit, PUR_Volume_Unit);
                    SetForeColor(Color.Orange, PUR_Base_Unit_Of_Measure_L, PUR_Division_L, PUR_GenItemCatGroup_L, PUR_Source_List_L, PUR_Purchasing_Group_L, PUR_Volume_Unit_L, PUR_Weight_Unit_L);
                    break;
                case "FINI":
                    if (FORM == "FORM-015")
                    {
                        PUR_Purchasing_Group.Text = "K03, Trading";
                        SetForeColor(Color.Orange, PUR_Purchasing_Group_L);
                        SetEnable(false, PUR_Purchasing_Group);
                    }
                    if (FORM == "FORM-TW-003")
                    {
                        //PUR_Plant.SelectedValue = "KT1P";
                        PUR_Purchasing_Group.Text = "K01, Raw Materials";
                        PUR_Plant_sp_matl.Text = "ZG";
                        PUR_MRP_Type.Text = "PD";
                        PUR_MRP_Controller.Text = "ERP";
                        PUR_Lot_Size.Text = "05";
                        PUR_Procurement_type.Text = "F";
                        PUR_Backflush.Text = "1";
                        PUR_Prod_ocation.Text = (Page as PMDC).TabMaterial1.Technical1.TEC_Storage_Location.Text;//"0";
                        PUR_SchedMargin_key.Text = "010";
                        PUR_Storage_locForEP.Text = (Page as PMDC).TabMaterial1.Technical1.TEC_Storage_Location.Text; //"0";
                        PUR_Period_Indicator.Text = "M";
                        PUR_Individual.Text = "2";
                        PUR_Source_List.Checked = true;
                        PUR_Availability_check.Text = "Z1";
                        SetForeColor(Color.Orange, PUR_Availability_check_L,PUR_Individual_L, PUR_Purchasing_Group_L, PUR_Source_List_L, PUR_Plant_sp_matl_L, PUR_MRP_Type_L, PUR_MRP_Controller_L, PUR_Lot_Size_L, PUR_Procurement_type_L, PUR_Backflush_L, PUR_Prod_ocation_L, PUR_SchedMargin_key_L, PUR_Storage_locForEP_L, PUR_Period_Indicator_L);
                        SetEnable(false, PUR_Individual,PUR_Availability_check, PUR_Purchasing_Group, PUR_Source_List, PUR_Plant_sp_matl, PUR_MRP_Type, PUR_MRP_Controller, PUR_Lot_Size, PUR_Procurement_type, PUR_Backflush, PUR_Prod_ocation, PUR_SchedMargin_key, PUR_Storage_locForEP, PUR_Period_Indicator);
                        
                        SetEnable(false, PUR_Purchasing_Group);
                    }
                    break;
            }
        }
        #endregion

        #region 方法 SetToolTip(设置控件 ToolTip)
        public void SetToolTip()
        {
            switch(Category)
            {
                case "RAW":
                    PUR_Fixed_Lot_Size.ToolTip          = "固定批量值";
                    PUR_Maximum_Lot_Size.ToolTip        = "最大批量值";
                    PUR_Minimum_Lot_Size.ToolTip        = "最小批量值";
                    PUR_Order_Unit.ToolTip              = "采购订单单位(仅当与Base Unit of Measure不同时填写, 且给出Base Unit of Measure的转换关系)";
                    PUR_Planned_Deliv_Time.ToolTip      = "计划内的交货时间(天)";
                    PUR_PO_Price.ToolTip                = "采购价";
                    PUR_Purchasing_Group.ToolTip        = "采购组(K01: Raw materials)";
                    PUR_Rounding_Value.ToolTip          = "采购订单数量的舍入值";
                    PUR_Source_List.ToolTip             = "源清单要求(默认勾)";
                    PUR_Special_Procurement.ToolTip     = "特殊获取类型";
                    PUR_Pack_Size.ToolTip               = "包装大小";
                    break;
                case "PACK":
                    PUR_Base_Unit_Of_Measure.ToolTip    = "基本单位(默认PC: Pieces)";
                    PUR_Bottom_Diameter.ToolTip         = "Holdingunit/round conical";
                    PUR_Decoration.ToolTip              = "黑白箱或彩箱Over pack";
                    PUR_Description_EN_1.ToolTip        = "包装产品容积(4bit)";
                    PUR_Description_EN_2.ToolTip        = "如果包装类型I中没有可选项，可以不选，但必须在包装类型II中做描述。";
                    PUR_Description_EN_3.ToolTip        = "如果包装类型I中没有可选项，可以不选，但必须在包装类型II中做描述。包装类型II(12bit)";
                    PUR_Description_EN_4.ToolTip        = "包装中英文描述(24bit)";
                    PUR_Description_ZH_1.ToolTip        = "包装产品容积(4bit)";
                    PUR_Description_ZH_2.ToolTip        = "如果包装类型I中没有可选项，可以不选，但必须在包装类型II中做描述。";
                    PUR_Description_ZH_3.ToolTip        = "如果包装类型I中没有可选项，可以不选，但必须在包装类型II中做描述。包装类型II(12bit)";
                    PUR_Description_ZH_4.ToolTip        = "包装中英文描述(24bit)";
                    PUR_Division.ToolTip                = "产品组(默认为10: General(incl. Exp.))";
                    PUR_GenItemCatGroup.ToolTip         = "普通项目类别(默认为NORM：Standard item)";
                    PUR_Height.ToolTip                  = "Holdingunit/cylindrical\nHoldingunit/recatangular normal\nHoldingunit/round conical\nLabel\nOver pack";
                    PUR_Internalcoating.ToolTip         = "是否内涂\nHoldingunit/cylindrical\nHoldingunit/recatangular normal\nHoldingunit/round conical";
                    PUR_Lab_Office.ToolTip              = "产品层次(Category + Segment)";
                    PUR_Length.ToolTip                  = "Holdingunit/recatangular normal\nLabel\nOver pack";
                    PUR_Order_Unit.ToolTip              = "采购订单单位（仅当与基本单位不同时使用）";
                    PUR_Purchasing_Group.ToolTip        = "采购组(默认为K02: PACK Materials)";
                    PUR_Source_List.ToolTip             = "货源清单要求（默认勾选）";
                    PUR_Top_Diameter.ToolTip            = "Holdingunit/cylindrical\nHoldingunit/round conical";
                    PUR_Width.ToolTip                   = "Holdingunit/recatangular normal";
                    PUR_Pack_Size.ToolTip               = "包装大小";
                    PUR_Gross_Weight.ToolTip            = "毛重（不超过3位小数）";
                    PUR_Net_Weight.ToolTip              = "净重（不超过3位小数）";
                    PUR_Weight_Unit.ToolTip             = "重量单位";
                    PUR_Volume_Unit.ToolTip             = "体积单位";
                    PUR_Volume.ToolTip                  = "体积";
                    break;
                case "FINI":
                    PUR_Order_Unit.ToolTip              = "采购订单单位";
                    if (FORM == "FORM-015")
                    {
                        PUR_Purchasing_Group.ToolTip = "采购组(默认为K03)";

                    }
                    else
                    {
                        PUR_Purchasing_Group.ToolTip = "采购组(only D plant need purchasing view\neg.K01D(K01P), K13D(K13P), K14D(K14P) ZFM                                           Others  K04）";
                    }
                    if (FORM.IndexOf("T") != -1)
                    {
                        PUR_Plant.ToolTip = "需要擴展的生產工廠";
                        PUR_Storage_Location.ToolTip = "需要擴展的倉位";
                        PUR_Purchasing_Group.ToolTip = "採購組(默認為K01)";
                        PUR_Plant_sp_matl.ToolTip = "工廠特定的物料狀態";
                        PUR_Source_List.ToolTip = "標識源清单要求（默认勾选）";
                        PUR_ABC_Indicator.ToolTip = "ABC標識";
                        PUR_MRP_Type.ToolTip = "物料需求計畫類型(默認為PD)";
                        PUR_Maximum_Lot_Size.ToolTip = "最大批量";
                        PUR_Minimum_Lot_Size.ToolTip = "最小批量";
                        PUR_MRP_Controller.ToolTip = "MRP控製者（物料計劃人）";
                        PUR_Lot_Size.ToolTip = "批量(物料計畫 默認為05)";
                        PUR_Procurement_type.ToolTip = "採購類型(默認為F)";
                        PUR_Rounding_Value.ToolTip = "採購訂單含量的捨入值";
                        PUR_Backflush.ToolTip = "標識反衡";
                        PUR_Prod_ocation.ToolTip = "發貨庫存地點";
                        PUR_SchedMargin_key.ToolTip = "浮動的計劃邊際碼";
                        PUR_Storage_locForEP.ToolTip = "外部採購的缺省倉儲位置";
                        PUR_Planned_Deliv_Time.ToolTip = "計畫天數內交貨";
                        PUR_Stock_det_grp.ToolTip = "庫存確定組";
                        PUR_Safty_Stock.ToolTip = "安全庫存";
                        PUR_Safety_time_ind.ToolTip = "安全時間標誌(含或不含安全時間)";
                        PUR_Availability_check.ToolTip = "可用性檢查的檢查組";
                        PUR_Safety_time_actcov.ToolTip = "安全時間(按工作日計算)";
                        PUR_Period_Indicator.ToolTip = "時間標誌(默認為M)";
                        PUR_Special_Procurement.ToolTip = "特殊采購類型";
                        PUR_Individual.ToolTip = "對于獨立和集中需求的相關需求標識";
                    }
                    break;
            }
        }
        #endregion

        #region 方法 DataValidation(数据验证)
        public List<string> DataValidation(mdc_Material mt, string Sheet)
        {
            //如果当前 Tabs 是隐藏的情况，退出
            List<Regular> regs = new List<Regular>();
            if (!(IsUsed && (Action == "C" || Action == "E")))
            {
                return new List<string>();
            }
            
            switch (Category)
            {
                case "SEFI":
                    break;
                case "RAW":
                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_PO_Price_L, (mt.PUR_PO_Price+"").Trim(), Sheet + "PO Price为必填");
                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Special_Procurement_L, mt.PUR_Special_Procurement, Sheet + "Special procurement为必填");
                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Pack_Size_L, mt.PUR_Pack_Size, Sheet + "Pack size为必填");
                    break;

                case "PACK":
                    Anthem.Label PACKtmpL = new Anthem.Label(); PACKtmpL.ForeColor = Color.Blue; PACKtmpL.Attributes["v"] = "1";
                    if (TaskAPI.Process != "NPL Master Data Application" || PUR_PO_Price.Text.Trim() == "&nbsp;")
                        akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_PO_Price_L, (mt.PUR_PO_Price+"").Trim(), Sheet + "PO Price为必填");
                        akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Classification_L, mt.PUR_Classification, Sheet + "Classification为必填");
                    //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Shape_L, mt.PUR_Shape, Sheet + "Shape为必填");
                    //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Top_Diameter_L, mt.PUR_Top_Diameter, Sheet + "Top diameter为必填");
                    //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Bottom_Diameter_L, mt.PUR_Bottom_Diameter, Sheet + "Bottom diameter为必填");
                    //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Height_L, mt.PUR_Height, Sheet + "Height为必填");
                    //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Length_L, mt.PUR_Length, Sheet + "Length为必填");
                    //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Width_L, mt.PUR_Width, Sheet + "Width为必填");
                    //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Internalcoating_L, mt.PUR_Internalcoating, Sheet + "Internal coating为必填");
                    //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Decoration_L, mt.PUR_Decoration, Sheet + "Decoration为必填");
                    //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Opening_Direction_L, mt.PUR_Opening_Direction, Sheet + "Opening direction为必填");

                    switch (mt.PUR_Classification)
                    {
                        default:
                            //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_PO_Price, Sheet + "PO Price为必填");
                            //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Classification, Sheet + "Classification为必填");
                            //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Shape, Sheet + "Shape为必填");
                            //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Top_Diameter, Sheet + "Top diameter为必填");
                            //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Bottom_Diameter, Sheet + "Bottom diameter为必填");
                            //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Height, Sheet + "Height为必填");
                            //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Length, Sheet + "Length为必填");
                            //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Width, Sheet + "Width为必填");
                            //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Internalcoating, Sheet + "Internal coating为必填");
                            //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Decoration, Sheet + "Decoration为必填");
                            //akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Opening_Direction, Sheet + "Opening direction为必填");
                            break;
                        case "Holdingunit":
                            switch (mt.PUR_Shape)
                            {
                                case "cylindrical":
                                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Shape, Sheet + "Shape为必填");
                                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Top_Diameter, Sheet + "Top diameter为必填");
                                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Height, Sheet + "Height为必填");
                                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Internalcoating, Sheet + "Internal coating为必填");
                                    break;
                                case "recatangular normal":
                                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Shape, Sheet + "Shape为必填");
                                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Height, Sheet + "Height为必填");
                                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Length, Sheet + "Length为必填");
                                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Width, Sheet + "Width为必填");
                                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Internalcoating, Sheet + "Internal coating为必填");
                                    break;
                                default :
                                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Shape, Sheet + "Shape为必填");
                                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Top_Diameter, Sheet + "Top diameter为必填");
                                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Bottom_Diameter, Sheet + "Bottom diameter为必填");
                                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Height, Sheet + "Height为必填");
                                    akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Internalcoating, Sheet + "Internal coating为必填");
                                    break;
                            }
                            break;
                        case "Label":
                            akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Height, Sheet + "Height为必填");
                            akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Length, Sheet + "Length为必填");
                            break;
                        case "Over pack":
                            akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Height, Sheet + "Height为必填");
                            akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Length, Sheet + "Length为必填");
                            akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PACKtmpL, mt.PUR_Decoration, Sheet + "Decoration为必填");
                            break;
                    }
                    break;
                case "FINI":
                    if (TaskAPI.Process == "TW New Raw Material Creation")
                    {
                        akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Material_Group_L,mt.PUR_Material_Group, "&nbsp;&nbsp; PUR_Material_Group 必填");
                        akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Plant_L, mt.PUR_Plant, "&nbsp;&nbsp;  Plant 必填");
                        akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Special_Procurement_L, mt.PUR_Special_Procurement, "&nbsp;&nbsp; Special Procurement 必填");
                        akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Storage_Location_L, mt.PUR_Storage_Location, "&nbsp;&nbsp; Storage Location 必填");
                        akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_ABC_Indicator_L, mt.PUR_ABC_Indicator, "&nbsp;&nbsp; ABC Indicator 必填");
                        akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Planned_Deliv_Time_L, mt.PUR_Planned_Deliv_Time, "&nbsp;&nbsp; Planned delivery time(days) 必填");
                        akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_Availability_check_L, mt.PUR_Availability_check, "&nbsp;&nbsp; Availability check 必填");
                        akzo_RegularCheck(ref regs, RegularExp.NotEmpty, PUR_PO_Price_L, (mt.PUR_PO_Price + "").Trim(), Sheet + "PO Price为必填");

     
                    }
                    break;
            }
            return Validation(regs);
        }
        #endregion
    }
}
      